package demo1;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.rmi.ServerException;

public class Demo {
    public static void main(String[] args) throws Exception {
//        1.编码
        Person person = new Person();
        person.sayHello();
//        2.反射机制
        Class<?> cls = Class.forName("demo1.Person");
        Person person1 = (Person) cls.newInstance();
        person1.sayHello();
//        3.spring
        AnnotationConfigApplicationContext context =
                new AnnotationConfigApplicationContext("demo1");
        Person bean = context.getBean(Person.class);
        bean.sayHello();

    }
}
